<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { Edit, Delete } from '@element-plus/icons-vue'

import addOrEdit from './addOrEdit.vue'
import pageContainer from '../../components/pageContainer.vue'
import {getPlayersInfoService} from '../../api/players.ts'

onMounted(() => {
  getPlayersList()
})
const playerListInfo = ref()

const getPlayersList = async () => {
  const res = await getPlayersInfoService()
  console.log(res);
  
  playerListInfo.value = res.data.data
}
</script>

<template>
  <pageContainer title="选手信息管理">
    <template #extra>
      <el-button type="primary" @click="addTeam">添加选手</el-button>
    </template>
    <el-table v-loading="loading" :data="playerListInfo" border style="width: 100%">
      <el-table-column type="index" label="序号" width="100" />
      <el-table-column label="选手姓名" prop="name"></el-table-column>
      <el-table-column label="id" prop="id"> </el-table-column>
      <el-table-column label="所属战队" prop="team"></el-table-column>
      <el-table-column label="分路" prop="role"></el-table-column>
      <el-table-column label="个人荣誉" prop="personalHonors"></el-table-column>
      <el-table-column label="相关赛事" prop="tournaments"></el-table-column>
      <el-table-column label="总击杀" prop="totalKills"></el-table-column>
      <el-table-column label="总胜场次" prop="totalWins"></el-table-column>
      <el-table-column fixed="right" label="操作" width="150">
        <template #default="{ row, $index }">
          <el-button
            type="primary"
            plain
            @click="editTeam(row, $index)"
            :icon="Edit"
            circle
          ></el-button>
          <el-button type="danger" plain :icon="Delete" circle @click="delTeam(row, $index)">
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <addOrEdit ref="dialog" @success="onSuccess"></addOrEdit>
  </pageContainer>
</template>
